/*
 * @Description: 属性相关数据库操作
 * @Author: pinus
 * @Email: pinus0716@163.com
 * @Git: https://gitee.com/xyf97
 * @Date: 2021-10-08 15:58:29
 * @LastEditTime: 2021-10-09 21:36:02
 */

const path = require('path')
const databaseModule = require(path.join(process.cwd(), 'modules/database'))

/**
 * @description: 获取参数列表数据
 * @param {*} cat_id
 * @param {*} sel
 * @param {*} cb
 * @return {*}
 */
module.exports.list = function (cat_id, sel, cb) {
  const db = databaseModule.getDataBase()
  sql = 'SELECT * FROM sp_attribute WHERE cat_id = ? AND attr_sel = ? AND delete_time is NULL'
  db.query(sql, { replacements: [cat_id, sel], type: db.QueryTypes.SELECT })
    .then(result => cb(null, result))
    .catch(err => cb('查询出错-' + err))
}
